@extends('layouts.admin')

@section('title', '班级配置-编辑')

@section('style')
    <link rel="stylesheet" type="text/css" href="{{asset('lib/bootstrap/css/bootstrap.min.css')}}" />
    <link rel="stylesheet" type="text/css" href="{{asset('lib/bootstrap/css/bootstrap-combobox.css')}}" />
    <link rel="stylesheet" type="text/css" href="{{asset('lib/bootstrap/css/multiple-select.css')}}" />
@endsection

@section('content')
    <article class="page-container">
        <form action="" method="post" class="form form-horizontal" id="form-techValue-add">
            <input type="hidden" value="{{$editEntity->id}}" name="id">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>班级名字：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="{{$editEntity->name}}" placeholder="" id="name" name="name">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>所属年纪：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <select class="combobox input-large form-control" name="grade_id" id="grade_id">
                        @foreach ($grades['data'] as $grade)
                            <option value="{{$grade['id']}}">{{$grade['name']}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>班主任：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <select class="combobox input-large form-control" name="header_teacher_user_id" id="header_teacher_user_id">
                        @foreach ($users['data'] as $user)
                            <option value="{{$user['id']}}">{{$user['name']}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>班级扩展配置：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <div class="row" style="margin-top: 0px;">
                        <div class="formControls col-xs-4 col-sm-3">
                            <select multiple="multiple" class="multiple w94" name="CLBUM_EXT_COURSE_LEADERS[]" id="CLBUM_EXT_COURSE_LEADERS">
                                @foreach ($CLBUM_EXT_COURSE_LEADERS['data'] as $da)
                                    <option value="{{$da['value']}}">{{$da['value_name']}}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="formControls col-xs-4 col-sm-3">
                            <select multiple="multiple" class="multiple w94" name="CLBUM_EXT_COURSE_TEACHERS[]" id="CLBUM_EXT_COURSE_TEACHERS">
                                @foreach ($CLBUM_EXT_COURSE_TEACHERS['data'] as $da)
                                    <option value="{{$da['value']}}">{{$da['value_name']}}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="formControls col-xs-4 col-sm-3">
                            <select multiple="multiple" class="multiple w94" name="CLBUM_EXT_STUDENT_LEADERS[]" id="CLBUM_EXT_STUDENT_LEADERS">
                                @foreach ($CLBUM_EXT_STUDENT_LEADERS['data'] as $da)
                                    <option value="{{$da['value']}}">{{$da['value_name']}}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">介绍：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <textarea name="desc" id="desc" cols="" rows="" class="textarea"  placeholder="一些介绍信息">{{$editEntity->desc}}</textarea>
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>
@endsection
@section('script')
    <script type="text/javascript" src="{{asset('lib/bootstrap/bootstrap-combobox.js')}}"></script>
    <script type="text/javascript" src="{{asset('lib/bootstrap/multiple-select.js')}}?snt=1"></script>
    <script>
        @foreach($editEntity->clbumExts as $clbumExt)
        $("#{{$clbumExt->system_code_type}}S option[value='{{$clbumExt->system_code_value}}']").attr("selected", true);
        @endforeach
        $('.combobox').combobox();
        $("#CLBUM_EXT_COURSE_LEADERS").multipleSelect({
            filter: true,
            position: 'top',
            placeholder: "课代表扩展"
        });
        $("#CLBUM_EXT_COURSE_TEACHERS").multipleSelect({
            filter: true,
            position: 'top',
            placeholder: "科任老师配置"
        });
        $("#CLBUM_EXT_STUDENT_LEADERS").multipleSelect({
            filter: true,
            position: 'top',
            placeholder: "班干部配置"
        });
        $(".input-text,.textarea").Huifocusblur();
        $(".textarea").Huitextarealength({
            minlength:0,
            maxlength:200.
        });
        $("#form-techValue-add").validate({
            rules:{
                name:{
                    required:true
                },
                grade_id:{
                    required:true,
                },
                header_teacher_user_id:{
                    required:true,
                },
                CLBUM_EXT_COURSE_LEADERS:{
                    required:true,
                },
                CLBUM_EXT_COURSE_TEACHERS:{
                    required:true,
                },
                CLBUM_EXT_STUDENT_LEADERS:{
                    required:true,
                },
                desc:{
                    maxlength:200,
                }
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                $(form).ajaxSubmit({
                    type: 'post',
                    url: "{{url('clbum/clbum/edit')}}",
                    success: function(data){
                        if(data['successFlag']==1){
                            layer_success_message("编辑成功!");
                            setTimeout(function(){
                                parent.$(".btnSearch").click();
                                layer_close();
                            },500);
                        }else{
                            layer_error_message(data['msg']);
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer_error_message('编辑失败!');
                    }
                });
            }
        });
    </script>
@endsection